﻿namespace cludg.Domain.Factory
{
	using Extensions;

	public class DomainObjectFactory
	{
		protected readonly DomainExtensionRegistry ExtensionRegistry;

		public DomainObjectFactory(DomainExtensionRegistry extensionRegistry)
		{
			ExtensionRegistry = extensionRegistry;
		}

		public TDomain Create<TDomain>() where TDomain : ExtendableEntity, new()
		{
			var result = new TDomain();
			result.InitExtensions(ExtensionRegistry.Get<TDomain>());
			return result;
		}

	}
}
